﻿using System;
using System.Xml.Serialization;
using System.Xml;

namespace ScheduleMVVM.Model.RuntimeFramework
{
    /// <summary>
    /// Represents a station within application logic
    /// </summary>
    public class StationEntry
    {
        /// <summary>
        /// Station name
        /// </summary>
        public String Title
        { get; set; }
        /// <summary>
        /// Branch of transportation system containing current station
        /// </summary>
        public String Department
        { get; set; }
        /// <summary>
        /// Internal station id used in SearchEngine calls
        /// </summary>
        public Int32 id
        { get; set; }
        // Overrides
        public override bool Equals(object obj)
        {
            if (obj is StationEntry)
            {
                StationEntry Obj = (StationEntry)obj;
                return Obj.id == this.id;
            }
            return base.Equals(obj);
        }
        public override int GetHashCode()
        {
            return id;    
        }
    }
    /// <summary>
    /// Represents a route within application logic, both a favourite route and a search query
    /// </summary>
    public class RouteEntry
    {
        /// <summary>
        /// Departure station
        /// </summary>
        public StationEntry startStation
        { get; set; }
        /// <summary>
        /// Arrival station
        /// </summary>
        public StationEntry endStation
        { get; set; }
        /// <summary>
        /// User defined favourite route name
        /// </summary>
        public String Title
        { get; set; }
        /// <summary>
        /// Contains the last time the route has been viewed
        /// </summary>
        public DateTime LastAccessTime
        { get; set; }
        /// <summary>
        /// Returns whether the route is a search query or a favourite entry
        /// </summary>
        public Boolean IsSearch
        { get; set; }
        // Overrides
        public override bool Equals(object obj)
        {
            if (obj is RouteEntry)
            {
                RouteEntry Obj = (RouteEntry)obj;
                return Obj.startStation == this.startStation && Obj.endStation == this.endStation;
            }
            return base.Equals(obj);
        }
        public override int GetHashCode()
        {
            return startStation.id*endStation.id;
        }
        public RouteEntry()
        {
            if (LastAccessTime == null) LastAccessTime = DateTime.Now;
        }
    }
}